package com.zhouyy.common.exception;

import com.zhouyy.common.enums.ApiResultCodeEnum;

/**
 * <p> 自定义异常类 </p>
 *
 * @author zhouyy
 * @description
 * @date 2024/03/25 19:16
 */
public class ApiException extends RuntimeException {

    /**
     * 异常状态码
     */
    private Integer code;

    public ApiException(Throwable cause) {
        super(cause);
    }

    public ApiException(String message) {
        super(message);
    }

    public ApiException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public ApiException(String message, Integer code) {
        super(message);
        this.code = code;
    }

    public ApiException(ApiResultCodeEnum response) {
        super(response.getDesc());
        this.code = response.getCode();
    }

    public ApiException(String message, Throwable cause) {
        super(message, cause);
    }

    public Integer getCode() {
        return code;
    }

}
